<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><title>Given a set of points (lat lon), get table of EJScreen API results near each — ejscreenapi_plus • EJAM</title><!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png"><link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png"><link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png"><link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png"><link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png"><link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png"><script src="../deps/jquery-3.6.0/jquery-3.6.0.min.js"></script><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link href="../deps/bootstrap-5.3.1/bootstrap.min.css" rel="stylesheet"><script src="../deps/bootstrap-5.3.1/bootstrap.bundle.min.js"></script><link href="../deps/font-awesome-6.4.2/css/all.min.css" rel="stylesheet"><link href="../deps/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet"><script src="../deps/headroom-0.11.0/headroom.min.js"></script><script src="../deps/headroom-0.11.0/jQuery.headroom.min.js"></script><script src="../deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js"></script><script src="../deps/clipboard.js-2.0.11/clipboard.min.js"></script><script src="../deps/search-1.0.0/autocomplete.jquery.min.js"></script><script src="../deps/search-1.0.0/fuse.min.js"></script><script src="../deps/search-1.0.0/mark.min.js"></script><!-- pkgdown --><script src="../pkgdown.js"></script><meta property="og:title" content="Given a set of points (lat lon), get table of EJScreen API results near each — ejscreenapi_plus"><meta name="description" content="Using EJScreen API without Shiny app interface"><meta property="og:description" content="Using EJScreen API without Shiny app interface"><meta property="og:image" content="https://usepa.github.io/EJAM/logo.svg"></head><body>
    <a href="#main" class="visually-hidden-focusable">Skip to contents</a>


    <nav class="navbar navbar-expand-lg fixed-top bg-light" data-bs-theme="light" aria-label="Site navigation"><div class="container">

    <a class="navbar-brand me-2" href="../index.html">EJAM</a>

    <small class="nav-text text-warning me-auto" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Released version">2.32.0</small>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>

    <div id="navbar" class="collapse navbar-collapse ms-3">
      <ul class="navbar-nav me-auto"><li class="active nav-item"><a class="nav-link" href="../reference/index.html">Reference</a></li>
<li class="nav-item dropdown">
  <button class="nav-link dropdown-toggle" type="button" id="dropdown-articles" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">Articles</button>
  <ul class="dropdown-menu" aria-labelledby="dropdown-articles"><li><hr class="dropdown-divider"></li>
    <li><h6 class="dropdown-header" data-toc-skip>Overview for EJAM Users</h6></li>
    <li><a class="dropdown-item" href="../articles/0_whatis.html">What is EJAM</a></li>
    <li><a class="dropdown-item" href="../articles/0_webapp.html">Using EJAM</a></li>
    <li><hr class="dropdown-divider"></li>
    <li><h6 class="dropdown-header" data-toc-skip>For analysts using R</h6></li>
    <li><a class="dropdown-item" href="../articles/1_installing.html">Installing the EJAM R package</a></li>
    <li><a class="dropdown-item" href="../articles/2_quickstart.html">Quick Start Guide</a></li>
    <li><a class="dropdown-item" href="../articles/3_analyzing.html">Basics of Using EJAM for Analysis in RStudio</a></li>
    <li><a class="dropdown-item" href="../articles/4_advanced.html">Advanced Features</a></li>
  </ul></li>
<li class="nav-item"><a class="nav-link" href="../news/index.html">Changelog</a></li>
      </ul><ul class="navbar-nav"><li class="nav-item"><form class="form-inline" role="search">
 <input class="form-control" type="search" name="search-input" id="search-input" autocomplete="off" aria-label="Search site" placeholder="Search for" data-search-index="../search.json"></form></li>
<li class="nav-item"><a class="external-link nav-link" href="https://github.com/USEPA/EJAM/" aria-label="GitHub"><span class="fa fab fa-github fa-lg"></span></a></li>
      </ul></div>


  </div>
</nav><div class="container template-reference-topic">
<div class="row">
  <main id="main" class="col-md-9"><div class="page-header">
      <img src="../logo.svg" class="logo" alt=""><h1>Given a set of points (lat lon), get table of EJScreen API results near each</h1>
      <small class="dont-index">Source: <a href="https://github.com/USEPA/EJAM/blob/HEAD/R/ejscreenapi_plus.R" class="external-link"><code>R/ejscreenapi_plus.R</code></a></small>
      <div class="d-none name"><code>ejscreenapi_plus.Rd</code></div>
    </div>

    <div class="ref-description section level2">
    <p>Using EJScreen API without Shiny app interface</p>
    </div>

    <div class="section level2">
    <h2 id="ref-usage">Usage<a class="anchor" aria-label="anchor" href="#ref-usage"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">ejscreenapi_plus</span><span class="op">(</span></span>
<span>  <span class="va">x</span>,</span>
<span>  y <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  radius <span class="op">=</span> <span class="fl">3</span>,</span>
<span>  unit <span class="op">=</span> <span class="st">"miles"</span>,</span>
<span>  wkid <span class="op">=</span> <span class="fl">4326</span>,</span>
<span>  fips <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  shapefile <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  namestr <span class="op">=</span> <span class="st">""</span>,</span>
<span>  report_every_n <span class="op">=</span> <span class="fl">100</span>,</span>
<span>  save_when_report <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  format_report_or_json <span class="op">=</span> <span class="st">"pjson"</span>,</span>
<span>  on_server_so_dont_save_files <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  ipurl <span class="op">=</span> <span class="st">"ejscreen.epa.gov"</span>,</span>
<span>  mapping_for_names <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  usewhichnames <span class="op">=</span> <span class="st">"r"</span>,</span>
<span>  calculate_ratios <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  verbose <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  getstatefromplacename <span class="op">=</span> <span class="cn">TRUE</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div class="section level2">
    <h2 id="arguments">Arguments<a class="anchor" aria-label="anchor" href="#arguments"></a></h2>


<dl><dt id="arg-x">x<a class="anchor" aria-label="anchor" href="#arg-x"></a></dt>
<dd><p>longitudes; or path/filename to xlsx or csv with lat, lon;
or data.frame or data.table with lat,lon</p></dd>


<dt id="arg-y">y<a class="anchor" aria-label="anchor" href="#arg-y"></a></dt>
<dd><p>latitudes, or ignored if x was a file or table with lat,lon info.</p></dd>


<dt id="arg-radius">radius<a class="anchor" aria-label="anchor" href="#arg-radius"></a></dt>
<dd><p>circular buffer radius (in miles by default, unless unit changed)</p></dd>


<dt id="arg-unit">unit<a class="anchor" aria-label="anchor" href="#arg-unit"></a></dt>
<dd><p>default is miles</p></dd>


<dt id="arg-wkid">wkid<a class="anchor" aria-label="anchor" href="#arg-wkid"></a></dt>
<dd><p>do not use. https://epsg.io/4326</p></dd>


<dt id="arg-fips">fips<a class="anchor" aria-label="anchor" href="#arg-fips"></a></dt>
<dd><p>if used instead of lon,lat it should be a character FIPS code vector
(counties, tracts, or blockgroups)</p></dd>


<dt id="arg-shapefile">shapefile<a class="anchor" aria-label="anchor" href="#arg-shapefile"></a></dt>
<dd><p>not implemented</p></dd>


<dt id="arg-namestr">namestr<a class="anchor" aria-label="anchor" href="#arg-namestr"></a></dt>
<dd><p>optional text</p></dd>


<dt id="arg-report-every-n">report_every_n<a class="anchor" aria-label="anchor" href="#arg-report-every-n"></a></dt>
<dd><p>default is to provide an update every so often</p></dd>


<dt id="arg-save-when-report">save_when_report<a class="anchor" aria-label="anchor" href="#arg-save-when-report"></a></dt>
<dd><p>default is FALSE but if TRUE it saves work in progress every so often</p></dd>


<dt id="arg-format-report-or-json">format_report_or_json<a class="anchor" aria-label="anchor" href="#arg-format-report-or-json"></a></dt>
<dd><p>do not use</p></dd>


<dt id="arg-on-server-so-dont-save-files">on_server_so_dont_save_files<a class="anchor" aria-label="anchor" href="#arg-on-server-so-dont-save-files"></a></dt>
<dd><p>default is FALSE, but set to TRUE if this is run on a server</p></dd>


<dt id="arg-ipurl">ipurl<a class="anchor" aria-label="anchor" href="#arg-ipurl"></a></dt>
<dd><p>change only if different URL has to be used for the EJScreen API</p></dd>


<dt id="arg-mapping-for-names">mapping_for_names<a class="anchor" aria-label="anchor" href="#arg-mapping-for-names"></a></dt>
<dd><p>a table that translates between original (as on FTP site),
short friendly (useful in coding or analysis),
and long complete variable names (for clearer Excel headers).
This can be read from a csv file or from data in a package.
Not documented here, as format may change.</p></dd>


<dt id="arg-usewhichnames">usewhichnames<a class="anchor" aria-label="anchor" href="#arg-usewhichnames"></a></dt>
<dd><p>default is to use the short friendly ones?</p></dd>


<dt id="arg-calculate-ratios">calculate_ratios<a class="anchor" aria-label="anchor" href="#arg-calculate-ratios"></a></dt>
<dd><p>whether to add columns with ratio of raw score to the US or State average</p></dd>


<dt id="arg-verbose">verbose<a class="anchor" aria-label="anchor" href="#arg-verbose"></a></dt>
<dd><p>whether to print to console / viewer / plot</p></dd>


<dt id="arg-getstatefromplacename">getstatefromplacename<a class="anchor" aria-label="anchor" href="#arg-getstatefromplacename"></a></dt>
<dd><p>set to FALSE if you need the exact output of API and
TRUE if you want to try to extract ST abbrev and statename from the placename field,
which is more likely to be correct than the stateAbbr and stateName fields in the API output.</p></dd>

</dl></div>
    <div class="section level2">
    <h2 id="value">Value<a class="anchor" aria-label="anchor" href="#value"></a></h2>
    <p>Returns a data.frame of results, one row per buffer (site), one column per indicator,
with over 300 columns.
<code><a href="ejscreenit.html">ejscreenit()</a></code> returns that as one element of a list that also has a map and plot.</p>
    </div>
    <div class="section level2">
    <h2 id="details">Details<a class="anchor" aria-label="anchor" href="#details"></a></h2>
    <p>See <code><a href="ejscreenit.html">ejscreenit()</a></code> for more details on this.
<code><a href="ejscreenit.html">ejscreenit()</a></code> uses functions below, but returns a list with table, map, plot, etc.
<code>ejscreenapi_plus()</code> accepts file or table or vectors of point data,
uses <code><a href="ejscreenapi.html">ejscreenapi()</a></code> to get EJScreen stats,
and then prepends input table and renames columns, to return a table.
<code><a href="ejscreenapi.html">ejscreenapi()</a></code>    gets EJ stats for many points as a data.table of many rows.
<code><a href="ejscreenapi1.html">ejscreenapi1()</a></code> gets EJ stats for 1 point via API, as data.frame of 1 row.
<code><a href="ejscreenRESTbroker.html">ejscreenRESTbroker()</a></code> gets EJ stats for one point as JSON.</p>
<p>It also now drops redundant columns where the same numbers had been returned from API
using the normal name and a synonym name, as with TOTALPOP and "totalPop"</p>
    </div>
    <div class="section level2">
    <h2 id="see-also">See also<a class="anchor" aria-label="anchor" href="#see-also"></a></h2>
    <div class="dont-index"><p><code><a href="ejscreenit.html">ejscreenit()</a></code> which also demonstrates a map and a plot,
and accepts filename as input pts. see <code><a href="ejscreenapi.html">ejscreenapi()</a></code> that
uses <code><a href="ejscreenapi1.html">ejscreenapi1()</a></code> and <code><a href="ejscreenRESTbroker.html">ejscreenRESTbroker()</a></code></p></div>
    </div>

    <div class="section level2">
    <h2 id="ref-examples">Examples<a class="anchor" aria-label="anchor" href="#ref-examples"></a></h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="kw">if</span> <span class="op">(</span><span class="cn">FALSE</span><span class="op">)</span>  <span class="co"># see [ejscreenit()] for examples</span></span>
<span>  <span class="va">pts</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html" class="external-link">data.frame</a></span><span class="op">(</span></span>
<span>   siteid <span class="op">=</span> <span class="fl">1</span><span class="op">:</span><span class="fl">2</span>,</span>
<span>   sitename <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"site A"</span>, <span class="st">"site B"</span><span class="op">)</span>,</span>
<span>   lon <span class="op">=</span>      <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="op">-</span><span class="fl">91.132107</span>, <span class="op">-</span><span class="fl">91.09</span><span class="op">)</span>,</span>
<span>   lat <span class="op">=</span>      <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">30.494982</span>,   <span class="fl">30.45</span><span class="op">)</span></span>
<span>  <span class="op">)</span></span>
<span>  <span class="co"># pts &lt;- testpoints_5</span></span>
<span>  </span>
<span>  <span class="va">myradius</span> <span class="op">&lt;-</span> <span class="fl">1</span></span>
<span>  </span>
<span>  <span class="va">x</span> <span class="op">&lt;-</span> <span class="va">testoutput_ejscreenapi_plus_5</span>; <span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="fu"><a href="fixcolnames.html">fixcolnames</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>, <span class="st">"r"</span>, <span class="st">"long"</span><span class="op">)</span></span>
<span>  <span class="co"># x &lt;- ejscreenapi_plus(pts,              radius = myradius, usewhichnames = "long")</span></span>
<span>  <span class="co"># x &lt;- ejscreenapi_plus(x = pts$lon, y = pts$lat, radius = myradius, usewhichnames = "long")</span></span>
<span>  <span class="co"># x &lt;- ejscreenapi_plus(pts,              radius = myradius, usewhichnames = "long")</span></span>
<span>  </span>
<span>  <span class="co">## view results</span></span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/t.html" class="external-link">t</a></span><span class="op">(</span><span class="va">x</span><span class="op">[</span><span class="fl">1</span>, <span class="fl">3</span><span class="op">:</span><span class="fu"><a href="https://rdrr.io/r/base/nrow.html" class="external-link">ncol</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">]</span><span class="op">)</span></span>
<span>  <span class="fu">DT</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/DT/man/datatable.html" class="external-link">datatable</a></span><span class="op">(</span><span class="va">x</span> , escape <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span>
<span>  </span>
<span>  <span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="fu"><a href="fixcolnames.html">fixcolnames</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span>, <span class="st">"long"</span>, <span class="st">"r"</span><span class="op">)</span></span>
<span>  <span class="fu"><a href="boxplots_ratios.html">boxplots_ratios</a></span><span class="op">(</span><span class="op">(</span><span class="fu"><a href="calc_ratios_to_avg.html">calc_ratios_to_avg</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span><span class="op">$</span><span class="va">ratios_d</span>, wheretext <span class="op">=</span> <span class="va">myradius</span><span class="op">)</span></span>
<span>  </span>
<span>  <span class="co"># \dontrun{}</span></span>
<span> </span></code></pre></div>
    </div>
  </main><aside class="col-md-3"><nav id="toc" aria-label="Table of contents"><h2>On this page</h2>
    </nav></aside></div>


    <footer><div class="pkgdown-footer-left">
  <p>US EPA 2024</p>
</div>

<div class="pkgdown-footer-right">
  <p>EJAM Version 2.32.0</p>
</div>

    </footer></div>





  </body></html>

